<?php
$this->Paginator->options(array('url' => array('ext' => false, '?' => $this->request->query)));
?>
<?php if (!empty($_filterQueries)) : ?>
    <div id="message-place">
        <?php
        $_url = '/' . $this->request->url;
        $_requestQueries = array_diff_key($this->request->query, array_flip($_filterQueries));
        if ($_requestQueries) {
            $_url .= '?' . http_build_query($_requestQueries);
        }
        echo $this->Layout->flash(__d('system', 'Filter results, %s to reset this filter', $this->Html->link(__d('system', 'click here'), $_url)), 'info');
        ?>
    </div>
<?php endif; ?>
<div class="section">
    <?php
    echo $this->element('toolbar');
    ?>
    <!-- Table -->
    <div class="table-wrapper">
        <?php echo $this->Form->create('Filter', array('url' => '/' . $this->request->url, 'type' => 'get')); ?>
        <div class="table-toolbar clearfix">
            <div class="input table-length">
                <?php
                echo __d('system', 'Show %s entries', $this->Form->input('limit', array('id' => 'filter-limit', 'options' => array(20 => 20, 50 => 50, 100 => 100), 'div' => false, 'label' => false)));
                ?>
            </div>
            <div class="table-filter">
                <div class="filter-keyword ui-corner-all">
                    <?php
                    echo $this->Form->input('q', array('id' => 'filter-keyword', 'size' => 30, 'div' => false, 'label' => false));
                    ?>
                    <a class="toggle" href="#"><span class="ui-icon ui-icon-triangle-1-s">Options</span></a>
                </div>
                <div class="filter-go">
                    <input value="Go" type="submit" id="filter-go" />
                </div>
                <div id="filter-options">
                    <div class="panel" class="clearfix"> 
                    </div>

                </div>
            </div>
        </div>



        <div id="table-options" style="display:none" class="table-options panel clearfix"></div>

        <?php echo $this->Form->end(); ?>
        <?php echo $this->Form->create('Paginate', array('id' => 'paginate', 'url' => $this->request->here(false), 'type' => 'post', 'inputDefaults' => array('label' => false))); ?>
        <div class="paginate-place">
            <div class="table-scroll">
                <div class="table-content">
                    <table>
                        <thead>
                            <tr>
                                <th>
                                    <span class="table-head table-select">
                                        <span class="ui-icon ui-icon-flag"></span>
                                        <input class="toggle" value="row-id" type="checkbox" title="<?php echo __d('system', 'Check all.'); ?>" />
                                    </span>
                                </th>
                                <?php if (isset($_displayFields['id'])): ?>
                                    <th>
                                        <span class="table-head">
                                            <?php echo $this->Paginator->sort('id', __d('system', 'Id')); ?>
                                        </span>
                                    </th>
                                <?php endif; ?>
                                <?php if (isset($_displayFields['name'])): ?>
                                    <th>
                                        <span class="table-head">
                                            <?php echo $this->Paginator->sort('name', __d('system', 'Name')); ?>
                                        </span>
                                    </th>
                                <?php endif; ?>
                                <?php if (isset($_displayFields['description'])): ?>
                                    <th>
                                        <span class="table-head">
                                            <?php echo $this->Paginator->sort('description', __d('system', 'Description')); ?>
                                        </span>
                                    </th>
                                <?php endif; ?>
                                <?php if (isset($_displayFields['domain'])): ?>
                                    <th>
                                        <span class="table-head">
                                            <?php echo $this->Paginator->sort('domain', __d('system', 'Domain')); ?>
                                        </span>
                                    </th>
                                <?php endif; ?>
                                <?php if (isset($_translateMaps)): ?>
                                    <th>    
                                        <span class="table-head">
                                            <span class="ui-icon ui-icon-gear"></span>
                                            <?php echo __d('system', 'Translate'); ?>                              
                                        </span>
                                    </th>
                                <?php endif; ?>
                                <th>
                                    <span class="table-head">
                                        <span class="ui-icon ui-icon-gear"></span>
                                        <?php echo __d('system', 'Action'); ?>
                                    </span>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $_row = 1;
                            $defaultLanguage = Router::defaultLanguage();
                            $_queries = array('continue' => $this->request->here(false));
                            ?>
                            <?php foreach ($regionals as $regional) : ?>
                                <tr class="table-row <?php echo $_row % 2 == 0 ? 'even' : 'odd'; ?>"> 
                                    <td class="table-col table-id">
                                        <?php echo $this->Form->input('id.', array('value' => $regional['Regional']['id'], 'class' => 'row-id', 'type' => 'checkbox', 'hiddenField' => false, 'id' => false)); ?>
                                    </td>
                                    <?php if (isset($_displayFields['id'])): ?>
                                        <td class="table-col table-integer">
                                            <?php echo $regional['Regional']['id']; ?>
                                        </td>
                                    <?php endif; ?>
                                    <?php if (isset($_displayFields['name'])): ?>
                                        <td class="table-col table-string">
                                            <?php echo String::truncate(strip_tags($regional['Regional']['name'])); ?>
                                        </td>
                                    <?php endif; ?>
                                    <?php if (isset($_displayFields['description'])): ?>
                                        <td class="table-col table-string">
                                            <?php echo String::truncate(strip_tags($regional['Regional']['description'])); ?>
                                        </td>
                                    <?php endif; ?>
                                    <?php if (isset($_displayFields['domain'])): ?>
                                        <td class="table-col table-string">
                                            <?php echo String::truncate(strip_tags($regional['Regional']['domain'])); ?>
                                        </td>
                                    <?php endif; ?>
                                    <?php if (isset($_translateMaps)): ?>
                                        <td class="table-col">
                                            <div class="table-translate">
                                                <?php
                                                foreach (Configure::read('Languages') as $_language) {
                                                    echo $this->Html->link($this->Html->image('flag/' . $_language['code'] . '.png'), array('action' => 'translate', $regional['Regional']['id'], $_language['code'], '?' => $_queries), array(
                                                        'class' => isset($_translateMaps[$regional['Regional']['id']][$_language['locale']]) ? '' : 'ui-state-disabled', 'escape' => false, 'title' => $_language['name']));
                                                }
                                                ?>
                                            </div>
                                        </td>
                                    <?php endif; ?>
                                    <td class="table-col">
                                        <div class="table-actions">
                                            <?php echo $this->Html->link('Edit', array('action' => 'edit', $regional['Regional']['id'], '?' => $_queries), array('title' => __d('system', 'Edit this item'), 'class' => 'ui-icon ui-icon-pencil')); ?>
                                            <?php echo $this->Html->link('Delete', array('action' => 'delete', '?' => array_merge($_queries, array('keys' => array($regional['Regional']['id'])))), array('title' => __d('system', 'Delete this item'), 'class' => 'ui-icon ui-icon-trash'), __d('system', 'Are you sure to delete #%s ?', $regional['Regional']['id'])); ?>


                                        </div>
                                    </td> 
                                </tr>
                                <?php $_row++; ?>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="table-toolbar ui-corner-bottom clearfix">
                <div class="table-info">
                    <?php echo $this->Paginator->counter(__d('system', 'Showing %start% to %end% of %count% entries')); ?>
                </div>
                <div class="table-paginate clearfix">
                    <?php echo $this->Paginator->first(__d('system', 'First')); ?>
                    <?php echo $this->Paginator->prev(__d('system', 'Prev'), array(), null, array('class' => 'disabled')); ?>
                    <?php echo $this->Paginator->numbers(array('separator' => '')); ?>
                    <?php echo $this->Paginator->next(__d('system', 'Next'), array(), null, array('class' => 'disabled')); ?>
                    <?php echo $this->Paginator->last(__d('system', 'Last')); ?>
                </div>
            </div>
        </div>
        <?php
        echo $this->Form->hidden('task', array('id' => 'task', 'value' => ''));
        echo $this->Form->end();
        ?>
    </div>
    <!-- /Table -->
</div>